import csv
import matplotlib.pyplot as plt
from numpy import *
import matplotlib.font_manager as fm

# 读取文件
with open('I:\\pyCharmProjectSet\\ToolSet\\data\\rubic\\segcna.tsv', newline='') as csvfile:
    csv_reader = csv.reader(csvfile, delimiter='\t', quotechar='|')
    probes = [row[4] for row in csv_reader]
    probesToInt = []
    for i in probes:
        probesToInt.append(int(i))
    # print(probesToInt)


    csvfile.seek(0)  # 让迭代器复位
    log_ratio = [row[5] for row in csv_reader]
    # print(log_ratio)

# 将读取的值弄成可读的点，便于画图
log_ratio_everyPoint=[]
point=[]
sum=0
for i in range(len(probesToInt)):
    for j in range(probesToInt[i]):
        sum+=1
        point.append(sum)
        log_ratio_everyPoint.append(log_ratio[i])
# print(sum)
# print(log_ratio_everyPoint)

x = []
y = []
sum = 0
# rows = eval(input("请输入样本数："))
# columns = eval(input("请输入探针数："))
rows = 60
columns = 500
for row in range(rows):
    x.append([])
    y.append([])
    sum = 0
    for column in range(columns):
        sum+=1
        x[row].append(sum)
        y[row].append((float)(log_ratio_everyPoint[sum]))

# 画散点图
f1 = plt.figure(figsize=(16, 96))  # 设置图片大小
# myfont = fm.FontProperties(fname='C:/Windows/Fonts/msyh.ttc')
# plt.title("探针拷贝数散点图",fontproperties=myfont)
# plt.xlabel("探针（第几个）",fontproperties=myfont)
# plt.ylabel("拷贝数值（log_ratio）",fontproperties=myfont)

for row in arange(rows):
    ax = plt.subplot(rows, 1, row + 1)
    plt.xlim(xmax=500,xmin=0)
    plt.ylim(ymax=5,ymin=-5)
    plt.plot(x[row],y[row],'.')   # ro代表红点，o代表小圆圈，-代表线
plt.show()


# for row in range(rows):
#     plt.subplot(rows,1,row+1)
#     plt.plot(x[row],y[row],'.')   # ro代表红点，o代表小圆圈，-代表线
# plt.show()

